package com.woniu.gf.pawn.utils;

import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;

import java.util.List;

public class BindingResultUtils {

    public static String getBindingResult(BindingResult result){
        StringBuilder sb=new StringBuilder();
        List<FieldError> fieldErrors = result.getFieldErrors();
        if(!fieldErrors.isEmpty()) {
            for (FieldError fieldError : fieldErrors) {
                sb.append(fieldError.getField()).append(":").append(fieldError.getDefaultMessage());
            }
        }
        return  sb.toString();
    }
}
